home *** CD-ROM | disk | FTP | other *** search
/ Freelog 115 / FreelogNo115-MaiJuin2013.iso / Internet / Filezilla Server / FileZilla_Server-0_9_41.exe / source / interface / misc / SystemTray.h < prev    next >
C/C++ Source or Header  |  2011-11-06  |  6KB  |  184 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. // SystemTray.h : header file
  3. //
  4. // Written by Chris Maunder (cmaunder@mail.com)
  5. // Copyright (c) 1998.
  6. //
  7. // This code may be used in compiled form in any way you desire. This
  8. // file may be redistributed unmodified by any means PROVIDING it is 
  9. // not sold for profit without the authors written consent, and 
  10. // providing that this notice and the authors name is included. If 
  11. // the source code in  this file is used in any commercial application 
  12. // then acknowledgement must be made to the author of this file 
  13. // (in whatever form you wish).
  14. //
  15. // This file is provided "as is" with no expressed or implied warranty.
  16. //
  17. // Expect bugs.
  18. // 
  19. // Please use and enjoy. Please let me know of any bugs/mods/improvements 
  20. // that you have found/implemented and I will fix/incorporate them into this
  21. // file. 
  22.  
  23. #ifndef _INCLUDED_SYSTEMTRAY_H_
  24. #define _INCLUDED_SYSTEMTRAY_H_
  25.  
  26. #ifdef NOTIFYICONDATA_V1_SIZE   // If NOTIFYICONDATA_V1_SIZE, then we can use fun stuff
  27. #define SYSTEMTRAY_USEW2K
  28. #else
  29. #define NIIF_NONE 0
  30. #endif
  31.  
  32. // #include <afxwin.h>
  33. #include <afxdisp.h>    // COleDateTime
  34.  
  35. /////////////////////////////////////////////////////////////////////////////
  36. // CSystemTray window
  37.  
  38. class CSystemTray : public CWnd
  39. {
  40. // Construction/destruction
  41. public:
  42.     CSystemTray();
  43.     CSystemTray(CWnd* pWnd, UINT uCallbackMessage, LPCTSTR szTip, HICON icon, UINT uID, 
  44.                 BOOL bhidden = FALSE,
  45.                 LPCTSTR szBalloonTip = NULL, LPCTSTR szBalloonTitle = NULL, 
  46.                 DWORD dwBalloonIcon = NIIF_NONE, UINT uBalloonTimeout = 10);
  47.     virtual ~CSystemTray();
  48.  
  49.     DECLARE_DYNAMIC(CSystemTray)
  50.  
  51. // Operations
  52. public:
  53.     BOOL Enabled() { return m_bEnabled; }
  54.     BOOL Visible() { return !m_bHidden; }
  55.  
  56.     // Create the tray icon
  57.     BOOL Create(CWnd* pParent, UINT uCallbackMessage, LPCTSTR szTip, HICON icon, UINT uID,
  58.            BOOL bHidden = FALSE,
  59.            LPCTSTR szBalloonTip = NULL, LPCTSTR szBalloonTitle = NULL, 
  60.            DWORD dwBalloonIcon = NIIF_NONE, UINT uBalloonTimeout = 10);
  61.  
  62.     // Change or retrieve the Tooltip text
  63.     BOOL    SetTooltipText(LPCTSTR pszTooltipText);
  64.     BOOL    SetTooltipText(UINT nID);
  65.     CString GetTooltipText() const;
  66.  
  67.     // Change or retrieve the icon displayed
  68.     BOOL  SetIcon(HICON hIcon);
  69.     BOOL  SetIcon(LPCTSTR lpszIconName);
  70.     BOOL  SetIcon(UINT nIDResource);
  71.     BOOL  SetStandardIcon(LPCTSTR lpIconName);
  72.     BOOL  SetStandardIcon(UINT nIDResource);
  73.     HICON GetIcon() const;
  74.  
  75.     void  SetFocus();
  76.     BOOL  HideIcon();
  77.     BOOL  ShowIcon();
  78.     BOOL  AddIcon();
  79.     BOOL  RemoveIcon();
  80.     BOOL  MoveToRight();
  81.  
  82.     BOOL ShowBalloon(LPCTSTR szText, LPCTSTR szTitle = NULL,
  83.                      DWORD dwIcon = NIIF_NONE, UINT uTimeout = 10);
  84.  
  85.     // For icon animation
  86.     BOOL  SetIconList(UINT uFirstIconID, UINT uLastIconID); 
  87.     BOOL  SetIconList(HICON* pHIconList, UINT nNumIcons); 
  88.     BOOL  Animate(UINT nDelayMilliSeconds, int nNumSeconds = -1);
  89.     BOOL  StepAnimation();
  90.     BOOL  StopAnimation();
  91.  
  92.     // Change menu default item
  93.     void GetMenuDefaultItem(UINT& uItem, BOOL& bByPos);
  94.     BOOL SetMenuDefaultItem(UINT uItem, BOOL bByPos);
  95.  
  96.     // Change or retrieve the window to send notification messages to
  97.     BOOL  SetNotificationWnd(CWnd* pNotifyWnd);
  98.     CWnd* GetNotificationWnd() const;
  99.  
  100.     // Change or retrieve the window to send menu commands to
  101.     BOOL  SetTargetWnd(CWnd* pTargetWnd);
  102.     CWnd* GetTargetWnd() const;
  103.  
  104.     // Change or retrieve  notification messages sent to the window
  105.     BOOL  SetCallbackMessage(UINT uCallbackMessage);
  106.     UINT  GetCallbackMessage() const;
  107.  
  108.     UINT  GetTimerID() const   { return m_nTimerID; }
  109.  
  110.     void RefreshIcon();
  111.  
  112. // Static functions
  113. public:
  114.     static void MinimiseToTray(CWnd* pWnd);
  115.     static void MaximiseFromTray(CWnd* pWnd);
  116.  
  117. public:
  118.     // Default handler for tray notification message
  119.     virtual LRESULT OnTrayNotification(WPARAM uID, LPARAM lEvent);
  120.  
  121. // Overrides
  122.     // ClassWizard generated virtual function overrides
  123.     //{{AFX_VIRTUAL(CSystemTray)
  124.     protected:
  125.     virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
  126.     //}}AFX_VIRTUAL
  127.  
  128. // Implementation
  129. protected:
  130.     void Initialise();
  131.     void InstallIconPending();
  132.  
  133. // Implementation
  134. protected:
  135.     NOTIFYICONDATA  m_tnd;
  136.     BOOL            m_bEnabled;         // does O/S support tray icon?
  137.     BOOL            m_bHidden;          // Has the icon been hidden?
  138.     BOOL            m_bRemoved;         // Has the icon been removed?
  139.     BOOL            m_bShowIconPending; // Show the icon once tha taskbar has been created
  140.     BOOL            m_bWin2K;           // Use new W2K features?
  141.     CWnd*           m_pTargetWnd;       // Window that menu commands are sent
  142.  
  143.     std::vector<HICON> m_IconList;
  144.     UINT         m_uIDTimer;
  145.     UINT         m_nCurrentIcon;
  146.     COleDateTime m_StartTime;
  147.     int          m_nAnimationPeriod;
  148.     HICON        m_hSavedIcon;
  149.     UINT         m_DefaultMenuItemID;
  150.     BOOL         m_DefaultMenuItemByPos;
  151.     UINT         m_uCreationFlags;
  152.  
  153. // Static data
  154. protected:
  155.     static BOOL RemoveTaskbarIcon(CWnd* pWnd);
  156.  
  157.     static const UINT m_nTimerID;
  158.     static UINT  m_nMaxTooltipLength;
  159.     static const UINT m_nTaskbarCreatedMsg;
  160.     static CWnd  m_wndInvisible;
  161.  
  162.     static BOOL GetW2K();
  163. #ifndef _WIN32_WCE
  164.     static void GetTrayWndRect(LPRECT lprect);
  165.     static BOOL GetDoWndAnimation();
  166. #endif
  167.  
  168. // Generated message map functions
  169. protected:
  170.     //{{AFX_MSG(CSystemTray)
  171.     afx_msg void OnTimer(UINT_PTR nIDEvent);
  172.     //}}AFX_MSG
  173. #ifndef _WIN32_WCE
  174.     afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
  175. #endif
  176.     LRESULT OnTaskbarCreated(WPARAM wParam, LPARAM lParam);
  177.     DECLARE_MESSAGE_MAP()
  178. };
  179.  
  180.  
  181. #endif
  182.  
  183. /////////////////////////////////////////////////////////////////////////////
  184.